package com.college.populator.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.college.domain.Student;
import com.college.domain.StudentContactDetails;
import com.college.domain.StudentPersonalDetails;
import com.college.helper.DateConversionHelper;
import com.college.populator.StudentRegistrationPopulator;

public class StudentRegistrationPopulatorImpl implements StudentRegistrationPopulator{
	
	@Autowired
	DateConversionHelper dateConversionHelper;
	
	public void studentRegistration(HttpServletRequest request, Student student){
		
		
		StudentContactDetails contactDetails=new StudentContactDetails();
		StudentPersonalDetails personalDetails=new StudentPersonalDetails();
		
		studentContactDetailstPopulation(request, contactDetails);
		studentPersonalDetailsPopulation(request, personalDetails);
		
		student.setRegistrationNo(request.getParameter(""));
		student.setJoiningDate(dateConversionHelper.stringToUtilDateConversion(request.getParameter("")));
		student.setCourse(request.getParameter(""));
		student.setCourseStartYear(Integer.parseInt(request.getParameter("")));
		student.setCourseEndYear(Integer.parseInt(request.getParameter("")));
		student.setContactDetails(contactDetails);
		student.setPersonalDetails(personalDetails);
		
		
		
	}
	
	private void studentContactDetailstPopulation(HttpServletRequest request, StudentContactDetails contactDetails){
		
		
		contactDetails.setPresentAddress(request.getParameter(""));
		contactDetails.setPermamentAddress(request.getParameter(""));
		contactDetails.setCity(request.getParameter(""));
		contactDetails.setState(request.getParameter(""));
		contactDetails.setCountry(request.getParameter(""));
		contactDetails.setPin(request.getParameter(""));
		contactDetails.setPhone(request.getParameter(""));
		contactDetails.setMobile(request.getParameter(""));
		contactDetails.setEmail(request.getParameter(""));
		
	}
	
	private void studentPersonalDetailsPopulation(HttpServletRequest request, StudentPersonalDetails personalDetails){
		
		personalDetails.setFirstName(request.getParameter(""));
		personalDetails.setMiddleName(request.getParameter(""));
		personalDetails.setLastName(request.getParameter(""));
		personalDetails.setDateOfBirth(dateConversionHelper.stringToUtilDateConversion(request.getParameter("")));
		personalDetails.setBloodGroup(request.getParameter(""));
		personalDetails.setGender(request.getParameter(""));
		personalDetails.setBirthPlace(request.getParameter(""));
		personalDetails.setNationality(request.getParameter(""));
		personalDetails.setMotherTongue(request.getParameter(""));
		personalDetails.setCategory(request.getParameter(""));
		personalDetails.setReligion(request.getParameter(""));
	}

}
